package cc.yugu.yhdw.common.tool.netty;

import io.netty.channel.ChannelHandlerContext;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.Map;

public class MessageProcessor implements Runnable {

    Logger log = LogManager.getLogger(MessageProcessor.class);

    public ChannelHandlerContext channelHandlerContext;
    public Object message;
    public Biz biz;
    public Map<String, Object> attributes;

    @Override
    public void run() {
        before();
        try {
            biz.doBiz(channelHandlerContext, attributes, message);
        } catch (Throwable e) {
            log.error("MessageProcessor execute error", e);
        } finally {
            after();
        }
    }

    protected void before() {
    }

    protected void after() {
    }
}